<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html><head><title>run-time-src\Lang.js--doc</title><link rel="stylesheet" href="screen.css" type="text/css" media="screen"><meta http-equiv='Content-Type' content='text/html; charset=UTF-8' /></head><body><div>
<table with='98%'><tr><td width='18%' valign='top'>
<div class='fn_index'>
<h3>File list</h3>
<ul>
<li><a href='Browser.html'>Browser.js</a>
<li><a href='DB.html'>DB.js</a>
<li><a href='File.html'>File.js</a>
<li><a href='Lang.html'>Lang.js</a>
<li><a href='Logging.html'>Logging.js</a>
<li><a href='Runtime.html'>Runtime.js</a>
<li><a href='Socket.html'>Socket.js</a>
<li><a href='UnitTest.html'>UnitTest.js</a>
<li><a href='json.html'>json.js</a>
</ul>
<h3>Global function</h3>
<ul>
</ul>
<h3>Class List</h3>
<ul>
<li><a href='#cls_Lang'>Lang</a></li>
<ul>
<li><a href='#__import__'>__import__(module, imports, scope)</a></li>
<li><a href='#apply'>apply(o, c, defaults)</a></li>
<li><a href='#cmp'>cmp(obj1, obj2)</a></li>
<li><a href='#dir'>dir(obj)</a></li>
<li><a href='#each'>each(obj, call_back, scope)</a></li>
<li><a href='#extend'>extend()</a></li>
<li><a href='#grep'>grep(filter, list, scope)</a></li>
<li><a href='#isArray'>isArray(obj)</a></li>
<li><a href='#len'>len(obj)</a></li>
<li><a href='#map'>map(converter, obj, scope)</a></li>
<li><a href='#max'>max(obj1, obj2)</a></li>
<li><a href='#min'>min(obj1, obj2)</a></li>
<li><a href='#str'>str(obj)</a></li>
</ul>
</ul>
</div>
</td><td with='80%'>
<div class='content'>
<div class='ctext'></div>
<div class='g_fun'><h3>Global function</h3>
</div>
<div class='cls'><h3>Class Lang</h3>
<div class='ctext'>
  defined same global function
  
  
</div>
<div class='pub_fn'><h3>Public method</h3>
<div class='fn'>
<div class='fn_sign'>
<span class='fn_name'>__import__</span>
(<span class='fn_arg'>module, imports, scope</span>)
&nbsp;return NameSpace
</div>
<div class='ctext'>
        import function from JS file in a special scope(namespace).
        
param: module -- a moduel name, should a JS file without the extension.
        <br/>
param: imports -- a list which function will be imported, default is 
        used exports list, defined by module self.<br/>
param: scope -- the scope of to import the functions, default is global
        JS object.
        
        
        </div>
<div class='example'><h4>Example:</h4>
        <pre><code>
            var unitTest = __import__('UnitTest', ['TestRunner'], {})
            var runner = new unitTest.TestRunner            
            
            //import all function of UnitTest to current JS global environment.
            __import__('UnitTest')
            var runner = new TestRunner()
        </code></pre>
        
    </div>
</div>
<div class='fn'>
<div class='fn_sign'>
<span class='fn_name'>apply</span>
(<span class='fn_arg'>o, c, defaults</span>)
&nbsp;return {Object} returns obj
</div>
<div class='ctext'>
 Copies all the properties of config to obj.


     
       Copy from(Ext-js)
 
 
 
 
 
     </div>
</div>
<div class='fn'>
<div class='fn_sign'>
<span class='fn_name'>cmp</span>
(<span class='fn_arg'>obj1, obj2</span>)
&nbsp;return Number
</div>
<div class='ctext'>
        To compare the two obj, return 1, 0 -1.
        if the two object is Array, compared the each items.
    
    
           
    </div>
</div>
<div class='fn'>
<div class='fn_sign'>
<span class='fn_name'>dir</span>
(<span class='fn_arg'>obj</span>)
&nbsp;return Array
</div>
<div class='ctext'>
       Return a list of the object.
    
        
        </div>
<div class='example'><h4>Example:</h4>
    <pre><code>
        var person = {name:'deownu', age:'99'};
        attr = dir(person);
        print(attr); //result: name, age
    </code></pre>   
    
    </div>
</div>
<div class='fn'>
<div class='fn_sign'>
<span class='fn_name'>each</span>
(<span class='fn_arg'>obj, call_back, scope</span>)
&nbsp;return Boolean
</div>
<div class='ctext'>
        To traversal the items of object by applying 'call_back' function. stoped
        if the 'call_back' return false. if the object have next(), it's called for iterating the 
     object, until the 'StopIterator' is throwed.
    
    
           
      </div>
<div class='example'><h4>Example:</h4>
    <pre><code>
        var person = {name:'deownu', age:'99'};
        
        each(dir(person), fn(e){
            print(e + ":" + person[e]); //print the attr and value.
        });
    </code></pre>
      </div>
<div class='example'><h4>Example:</h4>
      
    <pre><code>
        var iterator = {i:100
                        next:function(){
                            if(i >= 110) throw "StopIterator"
                            return this.i++;
                        }}
        
        each(iterator, fn(e, i){
            print(e, i); 
        });
    </code></pre>       
             </div>
</div>
<div class='fn'>
<div class='fn_sign'>
<span class='fn_name'>extend</span>
(<span class='fn_arg'></span>)
&nbsp;return {Function} The subclass constructor.
</div>
<div class='ctext'>
 Extends one class with another class and optionally overrides members with the passed literal. This class
 also adds the function "override()" to the class that can be used to override
 members on an instance.
 * <p>
 This function also supports a 2-argument call in which the subclass's constructor is
 not passed as an argument. In this form, the parameters are as follows:</p><p>
 <div class="mdetail-params"><ul>
 <li><code>superclass</code>
 <div class="sub-desc">The class being extended</div></li>
 <li><code>overrides</code>
 <div class="sub-desc">A literal with members which are copied into the subclass's
 prototype, and are therefore shared among all instances of the new class.<p>
 This may contain a special member named <tt><b>constructor</b></tt>. This is used
 to define the constructor of the new class, and is returned. If this property is
 <i>not</i> specified, a constructor is generated and returned which just calls the
 superclass's constructor passing on its parameters.</p></div></li>
 </ul></div></p><p>
         
         Copy from(Ext-js)
         </div>
<div class='example'><h4>Example:</h4>
         For example, to create a subclass of the Ext GridPanel:
         <pre><code>
    MyGridPanel = Ext.extend(Ext.grid.GridPanel, {
        constructor: function(config) {
            // Your preprocessing here
            MyGridPanel.superclass.constructor.apply(this, arguments);
            // Your postprocessing here
        },

        yourMethod: function() {
            // etc.
        }
    });
</code></pre>
 </p>
 
 
 
 prototype, and are therefore shared between all instances of the new class.
 
         </div>
</div>
<div class='fn'>
<div class='fn_sign'>
<span class='fn_name'>grep</span>
(<span class='fn_arg'>filter, list, scope</span>)
&nbsp;return Array
</div>
<div class='ctext'>
        Return a sub list of the argument list, filted the item by firstly
        argument. if the item will returned if executing the filter with item 
        return true.
        the 'grep' function called 'each' function to traversal list, so any type
        of object supported by 'each' can passed as 'grep' function.
        
        
        
        </div>
<div class='example'><h4>Example:</h4>
        filter a array list.        
        <pre><code>
            list = [1,2,3,4]
            new_list = grep(function(e,i){return e > 2}, list);
            print(new_list) //result is [3, 4]
            
            //other simple way, pass a string as filter function. this '$' is 
            items of list.
            new_list = grep("$+100", list);
            
        </code></pre>
        </div>
<div class='example'><h4>Example:</h4>
        filter a object.        
        <pre><code>
            obj = {t1:100, t2:200, t3:300}            

            new_obj = grep("$>100", obj);
            
            print(dir(new_obj)); //result is [t2, t3]
            
        </code></pre>        
        
    </div>
</div>
<div class='fn'>
<div class='fn_sign'>
<span class='fn_name'>isArray</span>
(<span class='fn_arg'>obj</span>)
&nbsp;return boolean
</div>
<div class='ctext'>
    check the object is a Array.
    
    </div>
</div>
<div class='fn'>
<div class='fn_sign'>
<span class='fn_name'>len</span>
(<span class='fn_arg'>obj</span>)
&nbsp;return boolean
</div>
<div class='ctext'>
    get the length of object. return count of attribute if the object isn't array.
    
    return undefined if the object can't count length.
    
    
    </div>
</div>
<div class='fn'>
<div class='fn_sign'>
<span class='fn_name'>map</span>
(<span class='fn_arg'>converter, obj, scope</span>)
&nbsp;return Array
</div>
<div class='ctext'>
        Return a list of the result of applying the function to the items of 
        a obj. used 'each' function to traversal the obj.
        
        
        
        </div>
<div class='example'><h4>Example:</h4>
        everty item of list added 100.
        <pre><code>
            list = [1,2,3,4]
            new_list = map(function(e,i){return e+100}, list);
            print(new_list) //result is [101, 102, 103, 104]
            
            //other simple way, apply a string as call function. this '$' is 
            items of list.
            new_list = map("$+100", list);
            
        </code></pre>
        
        
    </div>
</div>
<div class='fn'>
<div class='fn_sign'>
<span class='fn_name'>max</span>
(<span class='fn_arg'>obj1, obj2</span>)
&nbsp;return obj
</div>
<div class='ctext'>
    return maximum object.
    
    </div>
</div>
<div class='fn'>
<div class='fn_sign'>
<span class='fn_name'>min</span>
(<span class='fn_arg'>obj1, obj2</span>)
&nbsp;return obj
</div>
<div class='ctext'>
     return minimal object.
    
    </div>
</div>
<div class='fn'>
<div class='fn_sign'>
<span class='fn_name'>str</span>
(<span class='fn_arg'>obj</span>)
&nbsp;return str
</div>
<div class='ctext'>
    convert object to JSON string.
    
    
    </div>
</div>
</div>
</div>
</div>
</td></tr></table>
</div></body></html>
